.POSIX:
PREFIX=	/usr/local
MANDIR=	man

HDR=	bezier.h
SRC=	main.c bezier.c

default: ffspline
all: default README
install: ffspline
	install -m 444 ffspline.1 ${DESTDIR}${PREFIX}/${MANDIR}/man1/
	install -m 755 ffspline ${DESTDIR}${PREFIX}/bin/
install-local: ffspline
	install -m 755 ffspline ${HOME}/bin/
ffspline: ${HDR} ${SRC} Makefile
	${CC} ${CFLAGS} ${LDFLAGS} -lm -o $@ ${SRC}
README: ffspline.1 Makefile
	mandoc -Ios= -Tutf8 ffspline.1 |\
	    awk '{gsub(/.\b/,"");a=b;b=c;c=$$0}FNR>4{print a}' > $@
clean:
	rm -f ffspline test.ff
clean-all: clean
	rm -f README
test: ffspline
	echo '0 256 256 512 512 256 256 0' | ./ffspline | \
	    feh --force-aliasing -
rand: ffspline
	jot -r 24 0 512 | ./ffspline | ff2png | feh --force-aliasing -
